import { Radio } from 'antd';
import type { SizeType } from 'antd/lib/config-provider/SizeContext';
import styles from './index.less';

type Tprops = {
  defaultValue?: string | number;
  onChange?: (e: any) => void;
  size?: SizeType;
  /** 类名注入 */
  className?: string | number;
  /** 按钮值 */
  options?: {
    label: string | number | boolean;
    value: string | number | boolean;
  }[];
  /** 外部传入当前选中值 */
  value?: string | number;
};

const Pointer = (props: Tprops) => {
  const { onChange, size, className, options, value } = props;

  return (
    <div className={`${styles.point} ${className}`}>
      <Radio.Group
        optionType="button"
        buttonStyle="solid"
        onChange={(e) => {
          onChange?.(e.target.value);
        }}
        size={size || 'small'}
        options={options}
        value={value}
      />
    </div>
  );
};

export default Pointer;
